/*
 * @Author: 41
 * @Date: 2022-02-17 18:34:12
 * @LastEditors: YWY
 * @LastEditTime: 2022-03-06 23:55:59
 * @Description: 
 */
import { resolve } from "path"
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteMockServe } from 'vite-plugin-mock'
function pathResolve(dir) {
  return resolve(__dirname, ".", dir);
}


// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      "@": pathResolve('src')
    }
  },
  plugins: [vue(),
    // viteMockServe({
    //   mockPath: "/src/mock",
    // }),
  ],
  server: {
    open: true,//启动项目自动弹出浏览器
    // port: 4000,//启动端口
    proxy: {
      '/api': {
        //如果要测试详情页请把target换成下面的注释
        // target: 'http://jsonplaceholder.typicode.com',
        target: 'http://cosine.ren:8000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/searchBaidu': {
        target: 'https://www.baidu.com/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/searchBaidu/, '')
      }
    }
  }

})
